/**
 * @author 黄波
 * 创建日期：2011Sep 4, 2011
 * TODO// N/A
 */
package com.platform.manager.action;

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import net.sf.json.JSONObject;

import com.platform.manager.bo.UserGroupPowerBo;
import com.platform.pojo.GroupPower;

//根据用户组ID，加载权限信息。返回json格式数据
public class LoadPowersIdAction extends ManagerSupport {

	private String groupId;
	private List<GroupPower> groupPowers;
	/**
	 * @return the groupId
	 */
	public String getGroupId() {
		return groupId;
	}
	/**
	 * @param groupId the groupId to set
	 */
	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}
	/**
	 * @return the groupPowers
	 */
	public List<GroupPower> getGroupPowers() {
		return groupPowers;
	}
	/**
	 * @param groupPowers the groupPowers to set
	 */
	public void setGroupPowers(List<GroupPower> groupPowers) {
		this.groupPowers = groupPowers;
	}
	@Override
	public String execute() throws Exception {
		String msg = null;
		if(groupId == null || groupId.equals("")) {
			msg = "请选择用户组！";
		} else {
			UserGroupPowerBo bo = new UserGroupPowerBo();
			groupPowers = bo.getPowers(groupId);
		}
		HashMap map = new HashMap();
		map.put("msg", msg);
		map.put("groupPowers", groupPowers);
		JSONObject json = JSONObject.fromObject(map);
		HttpServletResponse response = ServletActionContext.getResponse();
		PrintWriter out = response.getWriter();
		response.setCharacterEncoding("utf-8");
		out.println(json.toString());
		out.flush();
		return null;
	}
	
}
